package com.xian.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.manage.domain.Handmade;
import com.xian.manage.service.IHandmadeService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 手作管理Controller
 * 
 * @author hanys
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/manage/handmade")
public class HandmadeController extends BaseController
{
    @Autowired
    private IHandmadeService handmadeService;

    /**
     * 查询手作管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:handmade:list')")
    @GetMapping("/list")
    public TableDataInfo list(Handmade handmade)
    {
        startPage();
        List<Handmade> list = handmadeService.selectHandmadeList(handmade);
        return getDataTable(list);
    }

    /**
     * 导出手作管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:handmade:export')")
    @Log(title = "手作管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Handmade handmade)
    {
        List<Handmade> list = handmadeService.selectHandmadeList(handmade);
        ExcelUtil<Handmade> util = new ExcelUtil<Handmade>(Handmade.class);
        util.exportExcel(response, list, "手作管理数据");
    }

    /**
     * 获取手作管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:handmade:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(handmadeService.selectHandmadeById(id));
    }

    /**
     * 新增手作管理
     */
    @PreAuthorize("@ss.hasPermi('manage:handmade:add')")
    @Log(title = "手作管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Handmade handmade)
    {
        return toAjax(handmadeService.insertHandmade(handmade));
    }

    /**
     * 修改手作管理
     */
    @PreAuthorize("@ss.hasPermi('manage:handmade:edit')")
    @Log(title = "手作管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Handmade handmade)
    {
        return toAjax(handmadeService.updateHandmade(handmade));
    }

    /**
     * 删除手作管理
     */
    @PreAuthorize("@ss.hasPermi('manage:handmade:remove')")
    @Log(title = "手作管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(handmadeService.deleteHandmadeByIds(ids));
    }
}
